<h1><?php echo $companyPage['name']; ?></h1>

<p>
    <?php
        // Check if company page has content, otherwise show ad text (kpl_text)
        if($companyPage['text']){
            echo nl2br($companyPage['text']);
        }
        else {
            echo $companyPage['cat'].'<br/>';
            echo nl2br($companyPage['link']);
        }

        echo '<br/><br/>';
    ?>
</p>


<br/>

<hr/>

<?php

    // List company ads
    $list = $companyAds;
    for($i=0;$i<count($list);$i++){
        echo '<h3>'.$list[$i]['company'].'</h3>';
        echo '<p>';
        echo nl2br($list[$i]['text']).'<br/>';
        echo '</p>';
        echo '<br/>';
    }

?>